<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Joomla! 2.5 JPagination 对象</title>
<link rel="stylesheet" href="../css/reset.css" />
<link rel="stylesheet" href="../css/prettify.css" />
<script type="text/javascript" src="../js/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<h1>Joomla! 2.5 JPagination 对象</h1>
<pre class="prettyprint linenums">JPagination Object
(
    [limitstart] =&gt; 0             // 当前页第一篇文章的 key 值
    [limit] =&gt; 5                  // 每页文章数
    [total] =&gt; 16                 // 总文章数
    [prefix] =&gt; 
    [_viewall:protected] =&gt; 
    [_additionalUrlParams:protected] =&gt; Array()
    [_errors:protected] =&gt; Array()
    [pages.total] =&gt; 4            // 总页数
    [pages.current] =&gt; 1          // 当前页码
    [pages.start] =&gt; 1            // 首页页码
    [pages.stop] =&gt; 4             // 末页页码
)</pre>
<h3>文章编号顺序生成</h3>
<pre class="prettyprint">
( [pages.current]-1 ) x [limit] = [limitstart]
( [pages.current]-1 ) x [limit] + [i] + 1 = [顺序文章编号]
[limitstart]                    + [i] + 1 = [数序文章编号]
</pre>
<h3>文章编号逆序生成</h3>
<pre class="prettyprint">
[limitstart]       + [i] + 1 = [顺序文章编号]
[total] - [顺序文章编号] + 1 = [逆序文章编号]
[tobal] - [limitstart] - [i] = [逆序文章编号]
</pre>
<h3>文章编号的应用</h3>
<pre class="prettyprint linenums">
$limitStart   = $this-&gt;pagination-&gt;get('limitstart');
$total        = $this-&gt;pagination-&gt;get('total');
// $pagesCurrent = $this-&gt;pagination-&gt;get('pages.current');
// $pagesLimit   = $this-&gt;pagination-&gt;get('limit');

foreach ($this-&gt;items as $i =&gt; $article) :
	printf("\n        ".'&lt;td class="list-number"&gt;%s&lt;/td&gt;' ,
		// $limitStart+$i+1
		$total-$limitStart-$i
	);
endforeach;
</pre>
</body>
</html>
